<template>
  <a-modal :open="open" width="550px" title="收费名称" centered @ok="onOk" @cancel="onCancel">
    <a-form class="mt-5 mb-10 pr-16" :model="formState" name="validate_other" :label-col="{ span: 6 }">
      <a-form-item label="支付方式名称">
        <a-input v-model:value="formState.zffsmc" placeholder="请输入" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script setup>
import { ref, watch } from 'vue'
import { message } from 'ant-design-vue'
import { post } from '@/utils/request'

const formState = ref({})
const props = defineProps({
  open: {
    type: Boolean,
    default: false
  },
  rowData: {
    type: Object,
    default: () => ({})
  }
})
const emit = defineEmits(['update:open', 'confirm', 'success'])

const onOk = async () => {
  const { code, msg } = await post('/operation/opex/doSavePaymentType', formState.value)
  if (code !== 0) return message.error(msg)
  message.success(msg)
  emit('update:open', false)
  emit('success')
}

const onCancel = () => {
  emit('update:open', false)
}
watch(
  () => props.open,
  (val) => {
    if (val) {
      formState.value = props.rowData
    }
  }
)
</script>
